package GlavFinans::Module::Manager;

use Modern::Perl;

use Data::Dumper;
use Mojo::Base 'Mojolicious';
use Mojo::Base 'Mojolicious::Plugin';
use Mojo::Loader;

has 'app';
has config => sub {{}};
has name => 'manager';

sub register {
	my ($self, $app, $conf) = @_;
	
	$app->routes->namespace('GlavFinans::Module::Core::Controller');
    
	my $r = $app->routes->bridge->to( controller => 'Auth', action => 'checkSession', layout => 'customer');
	my $a = $r->bridge->to( controller => 'Auth', action => 'checkAuth');

	# route = [ 
	#	[ get|post|route ... , 
	#     Match URL,
	#     Controller,
	#     Action
	#     route name]
	# ]
				
	my $route = {
		'anon' => {
			'bridge'    => $r,
			'layout'    => 'frontend',
			'namespace' => 'GlavFinans::Module::Manager::Controller',
			'route'     => []

		},
		'auth' => {
			'layout' => 'manager',
			'bridge' => $a,
			'route'  => [
				['get',   '/manager',  'Front', 'index',  'manager_front_index']
			]
		}
	};
	
	$app->route($route);
}

1;